package com.hdax.dm.utils.response;

import com.hdax.dm.exceptions.DmException;
import lombok.Data;

/**
 * 公共响应数据
 */
@Data
public class CommonResponse<T> {
    private String success;
    private String errorCode;
    private String msg;
    private T data;

    //成功响应

    public CommonResponse(T data){
        this.success = "success";
        this.errorCode = "0000";
        this.msg = "msg";
        this.data = data;
    }
  //成功响应

    public CommonResponse(T data,String msg){
        this.success = "success";
        this.errorCode = "0000";
        this.msg = msg;
        this.data = data;
    }

    // 失败响应

    public CommonResponse(String errorCode,String msg){
        this.errorCode = errorCode;
        this.msg = msg;
    }
    public CommonResponse(DmException e){
        this.errorCode = e.getErrorCode();
        this.msg = e.getMessage();
    }
}
